package main

import (
	"github.com/zhang-jianqiang/api/config"
	tracer "github.com/zhang-jianqiang/api/config/stracer"
	"github.com/zhang-jianqiang/api/router"
	"go-micro.dev/v4/web"
	"log"
)

var (
	service = "api"
	version = "latest"
)

func main() {
	// 配置jaeger连接
	closer, err := tracer.NewJaegerTracer(service, "127.0.0.1:6831")
	if err != nil {
		log.Fatal(err)
	}
	defer closer.Close()

	r := router.InitRouter()
	// Create service
	srv := web.NewService(
		web.Name(service),
		web.Version(version),
		web.Registry(config.NewNacosRegistry().Register()),
		web.Metadata(map[string]string{"version": version}),
		web.Address(":8082"),
		web.Handler(r),
	)
	err = srv.Init()
	if err != nil {
		log.Fatal(err)
	}

	// Run service
	if err := srv.Run(); err != nil {
		log.Fatal(err)
	}
}
